package com.pv.bfc.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.springframework.transaction.annotation.Transactional;

@Entity
@Transactional
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "BRIEFCASEUSER")
public class BriefcaseUser implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	private String userName;

	@Column(name = "FIRST_NAME")
	private String firstName;

	@Column(name = "LAST_NAME")
	private String lastName;

	@Column(name = "EMAIL")
	private String email;

	@Column(name = "PASSWORD")
	private String password;

	@Column(name = "CONFIRMPASSWORD")
	private String confirmPassword;

	/*
	 * @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy =
	 * "user") private List<Folder> folders = new ArrayList<Folder>();
	 * 
	 * @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL) private
	 * List<Comments> comments = new ArrayList<Comments>();
	 */

	public BriefcaseUser() {

	}

	public BriefcaseUser(String userName, String firstName, String lastName,
			String email, String password, String confirmPassword) {
		super();
		this.userName = userName;
		this.firstName = firstName;
		this.lastName = lastName;
		this.email = email;
		this.password = password;
		this.confirmPassword = confirmPassword;
	}

	/*
	 * @Transient public void addFolder(Folder folderToAdd) {
	 * folderToAdd.setUser(this); getFolders().add(folderToAdd); }
	 * 
	 * 
	 * public void addComment(Comments comment) { comments.add(comment); }
	 */

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	/*
	 * public List<Folder> getFolders() { return folders; }
	 * 
	 * public void setFolders(List<Folder> folders) { this.folders = folders; }
	 * 
	 * public List<Comments> getComments() { return comments; }
	 * 
	 * public void setComments(List<Comments> comments) { this.comments =
	 * comments; }
	 */

	public String getConfirmPassword() {
		return confirmPassword;
	}

	public void setConfirmPassword(String confirmPassword) {
		this.confirmPassword = confirmPassword;
	}

	public int hashCode() {
		final int PRIME = 31;
		int result = 1;
		result = PRIME * result + ((email == null) ? 0 : email.hashCode());
		result = PRIME * result
				+ ((firstName == null) ? 0 : firstName.hashCode());
		result = PRIME * result
				+ ((lastName == null) ? 0 : lastName.hashCode());
		result = PRIME * result
				+ ((password == null) ? 0 : password.hashCode());
		result = PRIME * result
				+ ((userName == null) ? 0 : userName.hashCode());
		return result;
	}

	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final BriefcaseUser other = (BriefcaseUser) obj;
		if (email == null) {
			if (other.email != null)
				return false;
		} else if (!email.equals(other.email))
			return false;
		if (firstName == null) {
			if (other.firstName != null)
				return false;
		} else if (!firstName.equals(other.firstName))
			return false;
		if (lastName == null) {
			if (other.lastName != null)
				return false;
		} else if (!lastName.equals(other.lastName))
			return false;
		if (password == null) {
			if (other.password != null)
				return false;
		} else if (!password.equals(other.password))
			return false;
		if (userName == null) {
			if (other.userName != null)
				return false;
		} else if (!userName.equals(other.userName))
			return false;
		return true;
	}

	public String toString() {
		return ToStringBuilder.reflectionToString(this,
				ToStringStyle.MULTI_LINE_STYLE);
	}

}
